<template>
	<view>
		<uni-forms ref="form">
			<uni-forms-item label="账号" name="">
				<uni-easyinput  v-model="form.username" placeholder="" />
			</uni-forms-item>
			<uni-forms-item label="密码" name="">
				<uni-easyinput  v-model="form.password" placeholder="" />
			</uni-forms-item>
			<button type="default" @click="reg">注册</button>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					username:'',
					password:'',
				}
			}
		},
		methods: {
			async reg(){
				console.log(this.form)
				if(this.form.username==""&&this.form.password==""){
					uni.showToast({
						icon:'error',
						title:"请输入用户名和密码"
					})
				}else{
					const {data} = await this.$request.register(this.form)
					console.log(data)
					this.info=data.data
					if(data.code==-1){
						uni.showToast({
							icon:"error",
							title:"用户名或密码错误"
						})
					}else{
						uni.showToast({
							icon:"success",
							title:"注册成功",
							success() {
								setTimeout(()=>{
									uni.navigateTo({
										url:"/pages/iphoneregister/iphoneregister"
									})
								},1500)
							}
						})
					}
				}
				
			}
			
		}
	}
</script>

<style>

</style>
